﻿using System.Windows.Forms;
using Ledict.Utility.Helper;

namespace Ledict.ConditionExtract.Base
{
    ///// <summary>
    ///// 基础窗体，继承Form
    ///// </summary>
    //public class BaseForm : Form
    //{

    //}

    /// <summary>
    /// 基础窗体，继承Form
    /// </summary>
    public partial class BaseForm : Form
    {
        //private static object _lock = new object();

        //private static T _instance;

        //public static T Instance
        //{
        //    get
        //    {
        //        if (_instance == null || _instance.IsDisposed)
        //        {
        //            lock (_lock)
        //            {
        //                if (_instance == null || _instance.IsDisposed)
        //                {
        //                    _instance = new T();
        //                }
        //            }
        //        }
        //        return _instance;
        //    }
        //}

        public BaseForm()
        {
            InitializeComponent();
        }


        /// <summary>
        /// 显示窗体，自动将窗体填满父窗体的工作区
        /// </summary>
        /// <param name="childForm"></param>
        protected virtual void ShowForm(Form childForm)
        {
            childForm.MdiParent = this;
            childForm.StartPosition = FormStartPosition.CenterParent;
            childForm.Show();
            childForm.Activate();//激活焦点
            childForm.Dock = DockStyle.Fill;

            //窗体是否最大化
            if (ConfigHelper.AppSettings("MidFormMax").Equals("true"))
            {
                childForm.WindowState = FormWindowState.Maximized;//最大化
            }


            var size = childForm.Size;
            var location = childForm.Location;
            ////childForm.Dock = DockStyle.None;
            childForm.Size = size;
            childForm.Location = location;
        }

    }
}
